-
-
Notifications
You must be signed in to change notification settings - Fork 30
fix: recursively resolve custom properties in no-invalid-properties #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: recursively resolve custom properties in no-invalid-properties #237
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the no-invalid-properties
ESLint rule where CSS custom properties containing chained var()
references were not being fully resolved before validation, causing lexer errors. The fix implements recursive resolution of custom properties to ensure all variables are resolved to their final values before being passed to the CSS lexer.
Key changes:
- Added recursive resolution logic for chained CSS custom properties
- Refactored variable resolution to handle fallback chains and cycles
- Added comprehensive test coverage for various chaining scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/rules/no-invalid-properties.js |
Implemented recursive variable resolution with new helper functions and refactored the main validation logic |
tests/rules/no-invalid-properties.test.js |
Added extensive test cases covering valid and invalid chained variable scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on this. Overall the code looks good, I think we just need some comments to help others understand how this works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Prerequisites checklist
What is the purpose of this pull request?
This PR prevents the lexer from receiving unresolved
var()
expressions by recursively resolving chained CSS custom properties. Previously the rule only performed a single-level replacement (e.g.--a: var(--b) → var(--b)
), so chained variables like--a: var(--b); --b: 80px;
could still leave var() in the value passed to the lexer, causingError: Matching for a tree with var() is not supported.
What changes did you make? (Give an overview)
Related Issues
Fixes #200
Is there anything you'd like reviewers to focus on?